home *** CD-ROM | disk | FTP | other *** search
/ Collection of Tools & Utilities / Collection of Tools and Utilities.iso / ada / gnat1792.zip / gnat179b / t-adainc / io.adb < prev    next >
Text File  |  1994-05-19  |  3KB  |  96 lines

  1. ------------------------------------------------------------------------------
  2. --                                                                          --
  3. --                         GNAT RUNTIME COMPONENTS                          --
  4. --                                                                          --
  5. --                                   I O                                    --
  6. --                                                                          --
  7. --                                 B o d y                                  --
  8. --                                                                          --
  9. --                            $Revision: 1.2 $                              --
  10. --                                                                          --
  11. --           Copyright (c) 1992,1993,1994 NYU, All Rights Reserved          --
  12. --                                                                          --
  13. -- GNAT is free software;  you can  redistribute it  and/or modify it under --
  14. -- terms of the  GNU General Public License as published  by the Free Soft- --
  15. -- ware  Foundation;  either version 2,  or (at your option) any later ver- --
  16. -- sion.  GNAT is distributed in the hope that it will be useful, but WITH- --
  17. -- OUT ANY WARRANTY;  without even the  implied warranty of MERCHANTABILITY --
  18. -- or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License --
  19. -- for  more details.  You should have  received  a copy of the GNU General --
  20. -- Public License  distributed with GNAT;  see file COPYING.  If not, write --
  21. -- to the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. --
  22. --                                                                          --
  23. ------------------------------------------------------------------------------
  24.  
  25. package body IO is
  26.  
  27.    procedure Get (X : out Integer) is
  28.       function Getint return Integer;
  29.       pragma Interface (C, Getint);
  30.       pragma Interface_Name (Getint, "get_int");
  31.    begin
  32.       X := Getint;
  33.    end Get;
  34.  
  35.    procedure Put (X : Integer) is
  36.       procedure Putint (X : Integer);
  37.       pragma Interface (C, Putint);
  38.       pragma Interface_Name (Putint, "put_int");
  39.    begin
  40.       Putint (X);
  41.    end Put;
  42.  
  43.    procedure Get (C : out Character) is
  44.       function Getchar return Character;
  45.       pragma Interface (C, Getchar);
  46.    begin
  47.       C := Getchar;
  48.    end Get;
  49.  
  50.    procedure Put (C : Character) is
  51.       procedure Putchar (C : Character);
  52.       pragma Interface (C, Putchar);
  53.    begin
  54.       Putchar (C);
  55.    end Put;
  56.  
  57.    procedure Put (S : String) is
  58.    begin
  59.       for I in S'range loop
  60.          Put (S (I));
  61.       end loop;
  62.    end Put;
  63.  
  64.    procedure Put_Line (S : String) is
  65.    begin
  66.       Put (S);
  67.       New_Line;
  68.    end Put_Line;
  69.  
  70.    procedure New_Line (Spacing : Positive := 1) is
  71.    begin
  72.       for I in 1 .. Spacing loop
  73.          Put (Ascii.LF);
  74.       end loop;
  75.    end New_Line;
  76.  
  77.    procedure Get_Line (Item : in out String; Last : out Natural) is
  78.       I_Length : Integer := Item'Length;
  79.       Nstore : Integer := 0;
  80.       C : Character;
  81.    begin
  82.       loop
  83.          Get (C);
  84.          exit when Nstore = I_Length;
  85.          if C = Ascii.Lf then
  86.             exit;
  87.          end if;
  88.          Item (Item'First + Nstore) := C;
  89.          Nstore := Nstore + 1;
  90.       end loop;
  91.       Last := Item'First + Nstore - 1;
  92.    end Get_Line;
  93.  
  94.  
  95. end IO;
  96.